import flash.display.Sprite;
import flash.events.MouseEvent;
import org.osflash.signals.DeluxeSignal;
import org.osflash.signals.natives.NativeSignal;
import org.osflash.signals.events.GenericEvent;

class Source extends Sprite {
	public var deluxe:DeluxeSignal;
	public var clicked:NativeSignal;

	public function new() {
		super();
		graphics.beginFill(0xcc1100);
		graphics.drawRect(0,0,100,100);
		graphics.endFill();

		deluxe = new DeluxeSignal(this);
		clicked = new NativeSignal(this,MouseEvent.CLICK,MouseEvent);
	}

	public function test() {
		deluxe.dispatch([new GenericEvent()]);
	}

	override public function toString() {
		return "Class Source";
	}
}

class Deluxe {
	var src : Source;

	public function new() {
		src = new Source();
		flash.Lib.current.addChild(src);

		src.deluxe.add(receiveEvent);
		src.clicked.add(receiveClick);
		src.test();
	}

	function receiveEvent(e:GenericEvent) {
		trace("Target is " + e.target);
		trace("Signal is " + e.signal);
	}

	function receiveClick(e:MouseEvent) {
		trace("Object was clicked");
	}

	public static function main() {
		var l = new Deluxe();
	}
}